NexusDeck Companion for the Mac
===============================

The companion is the small counterpart to the NexusDeck app on iPhone and iPad.
It runs on your Mac and carries out what you tap in NexusDeck: pressing keys,
launching programs, changing the volume, showing values from the Mac.

Requirements
- a Mac with a current version of macOS
- iPhone or iPad with NexusDeck on the SAME Wi-Fi / network as the Mac
- Internet access on the first start (add-on packages are downloaded)


1. Extract
----------
Double-click the ZIP file. Move the resulting "NexusDeck Companion" folder to
a permanent place, e.g. "Documents".


2. Start
--------
In the folder, double-click "Start-macOS.command".

- The very first time, macOS says the file could not be verified. Then:
  "Done" › System Settings › Privacy & Security › at the very bottom next to
  "Start-macOS.command" click "Open Anyway" › confirm.
  This is only needed once.
- If Python 3 is missing, macOS offers to install the "command line developer
  tools" › "Install". Then run Start-macOS.command again.
- On the first start the companion downloads its add-on packages. This takes a
  few minutes; the Terminal window shows the progress and closes afterwards.
- If macOS asks about the local network or incoming connections: "Allow".
  Without this, your iPhone cannot connect.

The "NexusDeck Companion" window then opens with a QR code.


3. Connect NexusDeck
--------------------
In NexusDeck tap "Connection" and scan the QR code in the companion window.
Done – the app then shows ONLINE at the top.
Without a camera: pick the Mac under "Found on Wi-Fi" and enter the pairing
token shown in the companion window.


4. Allow key presses
--------------------
So the companion may press keys: System Settings › Privacy & Security ›
Accessibility › switch on "Terminal" (and "Python" if it is listed).
Restart the companion afterwards.


Good to know
------------
- LIVE / TEST: at the top of the companion window. Only in LIVE does the
  companion really press keys; in TEST actions are only shown.
- Start with the Mac: switch on "Start with the computer" in the companion
  window. The companion then starts every time you log in (icon in the
  menu bar).
- Closing the window quits the companion.
- Launching programs: NexusDeck may only open programs that you allow in the
  companion window under "Applications for NexusDeck".
- Everything stays on your network. Only devices with the pairing token can
  control the companion.


Installing a new version
------------------------
1. Quit the companion (close the window or menu bar icon › Quit).
2. Extract the new ZIP file and copy its files into your existing
   "NexusDeck Companion" folder ("Replace").
3. Run Start-macOS.command.
Pairing, program permissions and settings are kept.
If NexusDeck shows a yellow "OUTDATED" at the top, a newer companion is needed.


Problems?
---------
- The iPhone cannot find the Mac: same Wi-Fi? Local network / firewall access
  allowed (System Settings › Network)?
- What happened during start-up is written to "companion.log" in the folder.
- Something went wrong during setup: delete the hidden subfolder ".venv"
  (Cmd-Shift-Period shows it in the Finder) and start again.


Removing
--------
Switch off "Start with the computer" in the companion window, quit the
companion and delete the "NexusDeck Companion" folder.


Optional: AI suggestions
------------------------
For "AI Studio" in NexusDeck the companion uses the on-device AI on Macs with
Apple Intelligence. Alternatively, your own OpenAI key works as the
environment variable OPENAI_API_KEY (OpenAI may charge for this).
Everything else works normally without AI.
